<template>
  <div class="dispatch common-tabs-wrapper">
    <el-form class="order-search" size="small" v-if="page == 'table'">
      <el-row type="flex">
        <el-form-item style="width: 130px" prop="cj">
          <el-select v-model="search.cj" clearable @change="getTableData">
            <template #prefix>车间：</template>
            <el-option
              v-for="item in cjOption"
              :key="item.id"
              :label="item['key_value']"
              :value="item['key_value']"
            />
          </el-select>
        </el-form-item>
        <el-form-item style="width: 130px" prop="gongxu">
          <el-select v-model="search.gongxu" clearable @change="getTableData">
            <template #prefix>工序： </template>
            <el-option
              v-for="item in gxOption"
              :key="item.id"
              :label="item['key_value']"
              :value="item['key_value']"
            />
          </el-select>
        </el-form-item>
      </el-row>
    </el-form>
    <el-tabs v-model="activeName" type="card">
      <el-tab-pane label="轮班管理" name="1">
        <Shift ref="shift" :query="search" />
      </el-tab-pane>
      <el-tab-pane label="班制设置" name="2">
        <Set />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import Shift from './modules/Shifts/Shift.vue';
import Set from './modules/Shifts/Set.vue';
export default {
  components: { Shift, Set },
  data() {
    return {
      activeName: '1',
      page: 'table',
      search: {
        cj: '',
        gongxu: '',
        org: '',
      },
    };
  },
  computed: {
    cjOption() {
      return this.$store.getters.cjOption;
    },
    bcOption() {
      return this.$store.getters.bcOption;
    },
    gxOption() {
      return this.$store.getters.gxOption;
    },
  },
  methods: {
    getTableData() {
      this.$refs.shift.getTableData(1)
    },
  },
};
</script>

<style lang="scss"></style>
